using Digitalmes.Domain.Entities.Mes.Processes;

namespace Digitalmes.Application.Mes.Processes.Routings.Commands;

/// <summary>
/// 工艺路线删除命令。
/// </summary>
/// <param name="RoutingId"></param>
public sealed record DeleteRoutingCommand(long RoutingId) : IRequest<IResult<bool>>;

internal sealed class DeleteRoutingCommandHandler(IRepository<ProcRouting> repo) : IRequestHandler<DeleteRoutingCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteRoutingCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.RoutingId, cancellationToken);
        return Result.From(ok);
    }
}
